package cn.itsource.config;

import cn.dev33.satoken.interceptor.SaInterceptor;
import cn.dev33.satoken.jwt.StpLogicJwtForStateless;
import cn.dev33.satoken.stp.StpLogic;
import cn.dev33.satoken.stp.StpUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


public class SaTokenConfigure implements WebMvcConfigurer {


    // 注册 Sa-Token 拦截器，打开注解式鉴权功能
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册 Sa-Token 拦截器，打开注解式鉴权功能
        registry.addInterceptor(new SaInterceptor(
                handle -> StpUtil.checkLogin()  //所有接口都需要拦截
        )).addPathPatterns("/**")
        .excludePathPatterns("/doc.html","/swagger-ui.html");
//        .excludePathPatterns("/user/doLogin");//excludePathPatterns排除哪个接口不需要拦截
    }
}